		
		
		

		*=======================================================================
		* Date: 17 March 2023
		* Paper: Effort and Social Comparison: Experimental Evidence from Uganda
		* Authors: prof. Ben d'Exelle, dr. Rik Habraken & prof. Arjan Verschoor 
		* 
		* Paper analyses
		*
		* Database(s) used: effortexperiment_2023.dta & money_burning_effort.dta
		*
		* Stata version: V15.0 SE
		*=======================================================================

	
	
		***open dataset
		use effortexperiment_2023.dta, clear
		
		***set font for graphs to TNR
		graph set window fontface "Times New Roman"		
		
		
		
		
		*************************		
		* Final earnings in UGX *
		*************************
		

		*section 2.3 in-text result on final earnings including show-up fee
		su final_payout
		bysort iqr_chancer: su final_payout	 
		


				
				
		******************************************************
		* Exclude chancer participants from further analyses *	
		******************************************************
				
		drop if iqr_chancer==1

				
		
		
		
		
		
		***************************************************
		* Table 2. Descriptive statistics of participants *
		***************************************************		
		
		***descriptives socio-economic characteristics (mean)
		estpost tabstat 														///
			gender pca_wealth bagisu_tribe totalsiblings educ_father 			///
			educ_mother, statistics(mean sd) columns(statistics)				///
			by(treatment)		
			
		tab gender treatment, chi2 col
		anova pca_wealth treatment
		tab bagisu_tribe treatment, chi2  col
		anova totalsiblings treatment
		tab educ_father treatment, chi2 col
		tab educ_mother treatment, chi2 col
		
		
		***descriptives effort round 1 (median)		
		estpost tabstat 														///
			totalansweredround1	correctround1 , statistics(median) 				///
			columns(statistics) by(treatment)		
			
		median totalansweredround1, by(treatment) exact  medianties(below)
		median correctround1, by(treatment) exact medianties(below)

		
		***number of subgroups and participants (collapse dataset for #subgroups)		
		preserve 
			
			collapse treatment, by(subgroup)
			tab subgroup treatment // note that subgroups are denoted as an ID
		
		restore

		***number of observations per treatment
		tab treatment			
			
			
			
			
		
		
		
		


		
		
	

		


	
				

		
		**************************************
		* Table 3. Average treatment effects *
		**************************************
			
		foreach v of varlist  dtotalansweredround  daccuracyround 				///
			dcorrectround dfalseround dearningsround dearningsabround {
		
			reg `v' i.treatment, vce(bootstrap, reps(2000) seed(840604) 		///
			cluster(school)) cluster(school)  		
			
			test i2.treatment =  i3.treatment
			test i2.treatment =  i4.treatment
			test i3.treatment =  i4.treatment

		}
		
			
		
		
		**************************************************		
		* Table 4. Inequality as driver of money-burning *
		**************************************************		
		
		
		***open long format dataset with money-burning decisions (3 per individual)
		use money_burning_effort.dta, clear	 
				
			
				
		***test for differences in money-burning by treatment				
		prtest burn, by(treatment)
				
		ttest amount_burned if burn==1, by(treatment)
				

				
		***individual fixed effects regression: burning decision
		xtreg burn diff_positive diff_negative if treatment==3, 				///
			fe i(ID1) vce(bootstrap, reps(2000) seed(840604) 					///
			cluster(ID1)) cluster(ID1)
					
		xtreg burn diff_positive diff_negative if treatment==4,					///
			fe i(ID1) vce(bootstrap, reps(2000) seed(840604) 					///
			cluster(ID1)) cluster(ID1)
					
		xtreg burn ib4.treatment##(c.diff_positive c.diff_negative), 			///
			fe i(ID1) vce(bootstrap, reps(2000) seed(840604)  					///
			cluster(ID1)) cluster(ID1)
		
		
		***individual fixed effects regression: amount burned
		xtreg amount_burned diff_positive diff_negative if 						///
			treatment==3, fe i(ID1) vce(bootstrap, reps(2000)   				///
			seed(840604) cluster(ID1)) cluster(ID1)
					
		xtreg amount_burned diff_positive diff_negative if 						///
			treatment==4, fe i(ID1) vce(bootstrap, reps(2000)  					///
			seed(840604) cluster(ID1)) cluster(ID1)
					
		xtreg amount_burned ib4.treatment##(c.diff_positive  					///
			c.diff_negative), fe i(ID1) vce(bootstrap, reps(2000) 				///
			seed(840604) cluster(ID1)) cluster(ID1)
					

	

	
	
		
		
		
		
		********************************************
		* Table 5. Heterogeneous treatment effects *
		********************************************
	
	
		***open dataset with effort variables
		use effortexperiment_2023.dta, clear
		
			
				
				******************************************************
				* Exclude chancer participants from further analyses *	
				******************************************************
						
				drop if iqr_chancer==1

				
		
		
		
		
		
		
		***Section 3.3. In-text tests between high and low performers *
		estpost ttest earningsround1 correctround1 falseround1   				///
				totalansweredround1 accuracyround1, by(high_performer)	
		

	
	
	
		***Treatment effects by rank in earnings in round 1: high vs low performers	
		foreach v of varlist dtotalansweredround daccuracyround  				///
			dcorrectround dfalseround dearningsround dearningsabround {
		
			*Panel a
			reg `v' i.treatment##i.high_performer ,vce(bootstrap, reps(2000)	///
			seed(840604) cluster(school)) cluster(school)  	
			
			*panel b
			margins, dydx(i.treatment) atmeans at(high_performer = 1)
			margins, at(treatment=1 high_performer=1) atmeans
		}
		
		
		
	

		
		
		
				
		
		*************************************
		* Table 6. Inequality within groups *
		*************************************
		
		*before money-burning
		ttest dist_earningsmeanr2 if treatment==2 | treatment==1, by(treatment)
		ttest dist_earningsmeanr2 if treatment==3 | treatment==1, by(treatment)
		ttest dist_earningsmeanr2 if treatment==4 | treatment==1, by(treatment)
		ttest dist_earningsmeanr2 if treatment==2 | treatment==3, by(treatment)
		ttest dist_earningsmeanr2 if treatment==2 | treatment==4, by(treatment)
		ttest dist_earningsmeanr2 if treatment==3 | treatment==4, by(treatment)
		
		*after money-burning
		ttest dist_abearningsmeanr2 if treatment==2 | treatment==1, by(treatment)
		ttest dist_abearningsmeanr2 if treatment==3 | treatment==1, by(treatment)
		ttest dist_abearningsmeanr2 if treatment==4 | treatment==1, by(treatment)
		ttest dist_abearningsmeanr2 if treatment==2 | treatment==3, by(treatment)
		ttest dist_abearningsmeanr2 if treatment==2 | treatment==4, by(treatment)
		ttest dist_abearningsmeanr2 if treatment==3 | treatment==4, by(treatment)
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		*************************************************************************		
		* Figure B.1. Within-change in number of completed tables, by treatment *
		*************************************************************************
		
		
		twoway histogram dtotalansweredround if treatment==1, freq width(1)  	///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("IF") 		///
			subtitle("") color(gs10) lcolor(gs16)	
			
		twoway histogram dtotalansweredround if treatment==2, freq width(1)  	///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("RF") 		///
			subtitle("") color(gs10) lcolor(gs16)
			
		twoway histogram dtotalansweredround if treatment==3, freq width(1)  	///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("RF_MB") 	///
			subtitle("") color(gs10) lcolor(gs16)
		
		twoway histogram dtotalansweredround if treatment==4, freq width(1)  	///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("IF_MB") 		///
			subtitle("") color(gs10) lcolor(gs16)			
			
		
		
		
		***********************************************************************		
		* Figure B.2. Within-change in number of correct tables, by treatment * 
		***********************************************************************		
		
		twoway histogram dcorrectround if treatment==1, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("IF") 		///
			subtitle("") color(gs10) lcolor(gs16)	
			
		twoway histogram dcorrectround if treatment==2, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("RF") 		///
			subtitle("") color(gs10) lcolor(gs16)
			
		twoway histogram dcorrectround if treatment==3, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("RF_MB") 	///
			subtitle("") color(gs10) lcolor(gs16)
		
		twoway histogram dcorrectround if treatment==4, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("IF_MB") 		///
			subtitle("") color(gs10) lcolor(gs16)			
			
	
		
		*************************************************************************		
		* Figure B.3. Within-change in number of incorrect tables, by treatment *
		*************************************************************************		
		
		
		twoway histogram dfalseround if treatment==1, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("IF") 									///
			subtitle("") color(gs10) lcolor(gs16)	
			
		twoway histogram dfalseround if treatment==2, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("RF") 									///
			subtitle("") color(gs10) lcolor(gs16)
			
		
		twoway histogram dfalseround if treatment==3, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("RF_MB") 								///
			subtitle("") color(gs10) lcolor(gs16)
		
		twoway histogram dfalseround if treatment==4, freq width(1)  			///
			graphregion(color(gs16))											///
			xlabel(-20(5)20, nogrid) ylabel(0(5)20, glcolor(gs15)) xtitle("") 	///
			ytitle("Frequency") b2title("IF_MB") 								///
			subtitle("") color(gs10) lcolor(gs16)			
			
			

			
		*******************************************************
		* Figure B.4. Within-change in earnings, by treatment *
		*******************************************************
		
		*ignoring money-burning costs
		
		twoway histogram dearningsround if treatment==1, freq width(500)  		///
			graphregion(color(gs16))											///
			xlabel(-5000(1000)5000, nogrid) ylabel(0(5)20, glcolor(gs15)) 		///
			xtitle("") ytitle("Frequency") b2title("IF") 						///
			subtitle("") color(gs10) lcolor(gs16)	
			
		twoway histogram dearningsround if treatment==2, freq width(500)  		///
			graphregion(color(gs16))											///
			xlabel(-5000(1000)5000, nogrid) ylabel(0(5)20, glcolor(gs15)) 		///
			xtitle("") ytitle("Frequency") b2title("RF") 						///
			subtitle("") color(gs10) lcolor(gs16)
			
		
		twoway histogram dearningsround if treatment==3, freq width(500)  		///
			graphregion(color(gs16))											///
			xlabel(-5000(1000)5000, nogrid) ylabel(0(5)20, glcolor(gs15)) 		///
			xtitle("") ytitle("Frequency") b2title("RF_MB") 					///
			subtitle("") color(gs10) lcolor(gs16)
		
		twoway histogram dearningsround if treatment==4, freq width(500)  		///
			graphregion(color(gs16))											///
			xlabel(-5000(1000)5000, nogrid) ylabel(0(5)20, glcolor(gs15)) 		///
			xtitle("") ytitle("Frequency") b2title("IF_MB") 					///
			subtitle("") color(gs10) lcolor(gs16)			
			
	
			
			
			
		
			
		*************************************************************
		* Table B.1. Descriptive statistics per round per treatment	*
		*************************************************************

		
		
		estpost tabstat 														///
			totalansweredround1	accuracyround1 correctround1 falseround1		///
			earningsround1 earningsabround1										///
			totalansweredround2	accuracyround2 correctround2 falseround2		///
			earningsround2 earningsabround2										///
			, statistics(mean sd median) columns(statistics) by(treatment)		
			
	
		
		
		
		
		
		***************************************************
		* Table B.2. Descriptive statistics per treatment *
		***************************************************
		
		estpost tabstat 														///
			dcorrectround daccuracyround  dtotalansweredround dfalseround 		///
			dearningsround dearningsabround, statistics(mean sd) 				///
			columns(statistics) by(treatment)		
			

					

		
		
		
		
		
		
		
		**************************************************************************************
		* Table B.3. Average treatment effects (without subgroups with at least one chancer) *
		**************************************************************************************
		
		foreach v of varlist dtotalansweredround  daccuracyround dcorrectround	///
			dfalseround dearningsround dearningsabround { 
			
			reg `v' i.treatment if chancer_in_subgroup==0, vce(bootstrap, 		///
				reps(2000) seed(840604) cluster(school)) cluster(school)  				
		}
		
		

			

		
		
		
		
		 
		
		
		************************************************************************
		* Table B.4. Treatment effects, by rank in tables completed in round 1 *
		************************************************************************
		
		
		foreach v of varlist  dtotalansweredround daccuracyround  dcorrectround ///
			dfalseround dearningsround dearningsabround {
		
		*panel a
			reg `v' i.treatment##i.high_performer_comp, vce(bootstrap, 			///
			reps(2000) seed(840604) cluster(school)) cluster(school)
		
		*panel b	
			margins, dydx(i.treatment) atmeans at(high_performer = 1)
			margins, at(treatment=1 high_performer=1) atmeans
		}
		
	


	
	
	
	
		****************************************************************
		* Table B.5. Treatment effects, by rank in accuracy in round 1 *
		****************************************************************
		
			
		foreach v of varlist dtotalansweredround daccuracyround dcorrectround  	///
			dfalseround dearningsround dearningsabround {
		
		*panel a
			reg `v' i.treatment##i.high_performer_acc, vce(bootstrap, 			///
			reps(2000) seed(840604) cluster(school)) cluster(school)   	
		
		*panel b	
			margins, dydx(i.treatment) atmeans at(high_performer = 1)
			margins, at(treatment=1 high_performer=1) atmeans
		}
		
			
	
	

				
		
		
		
		
		
		
		
		*************************
		* Appendix C. Footnotes *
		*************************		
		
		use effortexperiment_2023.dta, clear
		
		
		
		ttest earningsround1, by(iqr_chancer)
		ttest earningsround2, by(iqr_chancer)
		
		oneway iqr_chancer treatment

		
		
		
		*****************************
		* Figure C.1. Scatter plots *
		*****************************
			
		
			
		*tables completed round 1
		
		graph twoway (scatter r1_chance_range totalansweredround1 				///
			if iqr_chancer==0, ylabel(0 (5) 25) jitter(1) msymbol(Oh) 			///
			mlcolor(gs10)) (scatter r1_chance_range totalansweredround1 		///
			if iqr_chancer==1, jitter(1) msymbol(S) mfcolor(gs3)				///
			mlcolor(gs3)), ytitle("Round 1 consecutive errors", height(7))		///
			xtitle("Total tables attempted round 1", height(7)) 				///
			legend(size(small) region(lcolor(gs10)) label(1 No guesser) 		///
			label(2 Guesser) ring(0) position(12) bmargin(medium)) 				///
			graphregion(color(white))

		*tables completed round 2
				
		graph twoway (scatter r2_chance_range totalansweredround2 				///
			if iqr_chancer==0, ylabel(0 (5) 25) jitter(1) msymbol(Oh) 			///
			mlcolor(gs10)) (scatter r2_chance_range totalansweredround2 		///
			if iqr_chancer==1, jitter(1) msymbol(S) mfcolor(gs3)				///
			mlcolor(gs3)), ytitle("Round 2 consecutive errors", height(7))		///
			xtitle("Total tables attempted round 2", height(7)) 				///
			legend(size(small) region(lcolor(gs10)) label(1 No guesser) 		///
			label(2 Guesser) ring(0) position(12) bmargin(medium)) 				///
			graphregion(color(white))
			
			

		
		
		*************************************************
		* Table C.1. Guessing vs. non-guessing students *
		*************************************************
			
			
			
		* descriptives socio-economic characteristics
		estpost tabstat 														///
			location gender pca_wealth bagisu_tribe totalsiblings firstborn		///
			 educ_father educ_mother, statistics(mean sd) columns(statistics) 	///
			 by(iqr_chancer)		

	
		* comparisons tests	
		prtest location, by(iqr_chancer)
		prtest gender, by(iqr_chancer)
		ttest pca_wealth, by(iqr_chancer)
		prtest bagisu_tribe, by(iqr_chancer) 
		ttest totalsiblings, by(iqr_chancer)
		prtest firstborn, by(iqr_chancer)
		prtest educ_father, by(iqr_chancer)
		prtest educ_mother, by(iqr_chancer)	
		
	
	
		
		*****************************************************************
		* Table C.2. Average treatment effects (with guessers included) *
		*****************************************************************
		
			
		foreach v of varlist  dtotalansweredround  daccuracyround dcorrectround	///
			dfalseround dearningsround dearningsabround {
		
			reg `v' i.treatment, vce(bootstrap, reps(2000) seed(840604) 		///
				cluster(school)) cluster(school)  		
					
			test i2.treatment =  i3.treatment
			test i2.treatment =  i4.treatment
			test i3.treatment =  i4.treatment

			
		}
		
	
		
	
	
	
	
	*********************************** END ***********************************
	
	
	
	
		
		
	




